package admin

import (
	"encoding/json"
	"fmt"
	"github.com/gin-contrib/sessions"
	"github.com/gin-gonic/gin"
	"mini-shop/models"
	"net/http"
)

type ProFileController struct {
	BaseController
}

func (con ProFileController) Index(c *gin.Context) {

	session := sessions.Default(c)
	userInfo :=session.Get("userinfo")

	var user []models.Manager
	var userinfoStruct []models.Manager

	userinfoStr, ok := userInfo.(string)
	if ok {
		json.Unmarshal([]byte(userinfoStr),&userinfoStruct)
	}


	fmt.Printf("%#v", user)
	c.HTML(http.StatusOK, "admin/profile/index.html", gin.H{
		"userInfo": userinfoStruct[0],
	})
}


